"""
7-2 水仙花数

水仙花数是指一个N位正整数（N≥3），它的每个位上的数字的N次幂之和等于它本身。本题要求编写程序,计算所有N位水仙花数。
使用Python来写的话，如果直接枚举会超时
似乎只能硬打表了
"""


def judge_narcissus_number(N, lowerlist ,upperlist):
    for number in range(lowerlist[N], upperlist[N]):
        move = number
        sum = 0
        while(move != 0):
            single = move % 10
            sum += pow(single, N)
            move = int(move / 10)
        if sum == number:
            print(number)


def resolution1():
    lowerlist = [0, 1, 10, 100, 1000, 10_000, 100_000,
                 1_000_000]
    upperlist = [1, 10, 100, 1000, 10_000, 100_000, 1_000_000,
                 10_000_000]
    N = int(input())
    judge_narcissus_number(N, lowerlist, upperlist)

# Python做算法防超时打表法
def resolution2():
    resultlist = [[],
                  [],
                  [],
                  [153, 370, 371, 407],
                  [1634, 8208, 9474],
                  [54748, 92727, 93084],
                  [548834],
                  [1741725, 4210818, 9800817, 9926315]]
    N = int(input())
    for item in resultlist[N]:
        print(item)

if __name__ == '__main__':
    # resolution1()
    resolution2()